package com.app.shop.service.shop.impl;


import com.app.shop.dao.wg.WgMemberMapper;
import com.app.shop.entity.WgMember;
import com.app.shop.entity.WgMemberExample;
import com.app.shop.entity.query.WgMemberQuery;
import com.app.shop.service.shop.WgMemberService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 订单服务
 *
 * @author chenliwei
 * @version v1.0 2019-3-11
 */
@Service("wgMemberService")
public class WgMemberServiceImp implements WgMemberService {

    private static final Logger log = LoggerFactory.getLogger(WgMemberServiceImp.class);

    @Autowired
    private WgMemberMapper wgMemberMapper;

    @Override
    public Page<WgMember> getWgMemberList(WgMemberQuery wgMemberQuery) {
        //查询条件
        WgMemberExample sysMenuExample = new WgMemberExample();
        WgMemberExample.Criteria criteria = sysMenuExample.createCriteria();
        //用户昵称
        if (wgMemberQuery.getNick() != null && wgMemberQuery.getNick().trim().length() > 0) {
            criteria.andNickLike('%' + wgMemberQuery.getNick() + '%');
        }
        //用户联系电话
        if (wgMemberQuery.getPhone() != null && wgMemberQuery.getPhone().trim().length() > 0) {
            criteria.andPhoneLike('%' + wgMemberQuery.getNick() + '%');
        }
        //用户性别
        if (wgMemberQuery.getGender() != null ) {
            criteria.andGenderEqualTo(wgMemberQuery.getGender());
        }
        //用户邮箱
        if (wgMemberQuery.getEmail() != null && wgMemberQuery.getEmail().trim().length() > 0) {
            criteria.andEmailLike('%' + wgMemberQuery.getEmail() + '%');
        }
        //模拟分页查询
        PageHelper.startPage(wgMemberQuery.getCurrentPage(), wgMemberQuery.getPageSize());
        return wgMemberMapper.selectByExample(sysMenuExample);
    }


}
